<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$system['name']}后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/layuimini/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <style>
        .filtrate-warp{
            margin-bottom: 10px;
        }
        .filtrate-warp .title{
            padding: 5px 12px 7px 12px;
            font-size: 14px;
            font-weight: normal;
            text-align: left;
            cursor: pointer;
            width: 90px;
            background-color: transparent!important;
            color: black!important;
        }

        .filtrate-warp .title:hover{
            color: black;
        }

        .filtrate-warp .flag{
            padding: 6px 12px 6px 12px;
            cursor: pointer;
        }

        .filtrate-warp .flag:hover{
            color: black;
        }

        .filtrate-warp .layui-badge:hover{
            color: white!important;
        }
    </style>
</head>
<body >
<div class="admin-main layui-anim layui-anim-upbit">
    <table class="layui-table" id="table-list" lay-filter="table-list"></table>
</div>
<script type="text/html" id="action">
    <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除</a>
</script>


<script type="text/html" id="topBtn">
    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius layui-btn-sm" id="add"><i class="layui-icon">&#xe608;</i>添加地区来源</button>
</script>


{include file="common/foot"/}
<script>
    layui.use(['easyadmin','table','form','upload','util','laydate'], function() {
        var table = layui.table,form = layui.form,laydate = layui.laydate, $ = layui.jquery,upload = layui.upload,util = layui.util,ea=layui.easyadmin;
        ea.listen();
        var tableIn = table.render({
            elem: '#table-list',
            url: '{:url("areaList")}',
            method: 'post',
            toolbar: '#topBtn',
            page: true,
            cols: [[
                {checkbox:true,fixed: true},
                {field: 'id', title: 'ID',  fixed: true},
                {field: 'area_name', title: '地区来源', },
                {field: 'add_time', title:'创建时间',templet:function (res) {
                        return util.toDateString(res.add_time = (res.add_time * 1000));
                    }},
                {title:'操作',width: 260, align: 'center', toolbar: '#action'}
            ]],
            limit: {$system['more']['admin_pagesize']} //每页默认显示的数量
        });

        $('body').on('click','#add',function() {
            ea.open('添加地区来源', "{:url('Clues/areaAdd')}",null,'260px');
        })


        table.on('tool(table-list)', function(obj) {
            var data = obj.data;

            if (obj.event === 'del') {
                layer.confirm('您确定要删除吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('areaDel')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===0){
                            layer.msg(res.msg,{time:2000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:2000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }else if(obj.event === 'edit'){
                ea.open("编辑地区来源","{:url('Clues/areaEdit')}?id="+data.id,null,'260px');
            }
        });


    });
</script>
</body>
</html>